﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Aspfm.Html
{
    [Serializable()]
    public class HCtrolType
    {
        public string name = "";
        public List<HCtrol> hclist = new List<HCtrol>();
        public List<HCtrolType> childType = new List<HCtrolType>();
    }
     [Serializable()]
    public class AspfmHistory
    {
        public List<string> filelist = new List<string>();
        public string SkinName = "";
    }
    [Serializable()]
    public class HCtrolAll
    {
        public HCtrol formmode = new HCtrol();
        public List<HCtrol> hclist = new List<HCtrol>();
        public HCtrolType childType = new HCtrolType();

        public static string GetConfigXml(string configname="")
        {
            if (string.IsNullOrEmpty(configname))
            {
                return Aspfm.Dal.DbFactory.CurrentPath(true) + "AspfmConfig\\" + "Aspfm.Config.xml";
            }
            return Aspfm.Dal.DbFactory.CurrentPath(true) + "AspfmConfig\\" + configname + ".xml"; 
        }
        public static HCtrolType GetConfigXmlAllType()
        {
            HCtrolType hcall = new HCtrolType();
            string[] files = System.IO.Directory.GetFiles(Aspfm.Dal.DbFactory.CurrentPath(true) + "AspfmConfig\\", "*.xml", System.IO.SearchOption.TopDirectoryOnly);
            Array.Sort(files);
            foreach (string strfile in files)
            {
                try
                {
                    object obj = Aspfm.Main.SerializeHelper.Load(typeof(HCtrolType), strfile);
                    if (obj != null && obj is HCtrolType)
                    {
                        hcall.childType.Add((HCtrolType)obj);
                    }
                }
                catch { }
            }
            return hcall;
        }
    }
    [Serializable()]
    public class HCtrol
    {
        public string name = "";
        public string html = "";
        public string remark = "";
        public string js = "";

        public HCtrol CopyHCtrol()
        {
            HCtrol hc = new HCtrol();
            hc.name = name;
            hc.html = html;
            hc.remark = remark;
            hc.js = js;
            return hc;
        }
    }
}
